<?php
App::uses('JsHelper', 'View/Helper');

class StarHelper extends JsHelper {
    public function __construct(View $view, $settings = array()) {
        parent::__construct($view, $settings);
        // debug($options);
    }
function stars($name, $options = array(), $nbstars, $function = null, $alert = null) {
 
    
   
 
    $script = "$('#{$options['id']}').stars({
                   rating_star_length: '{$nbstars}',
                   id: '{$options['id']}',
                   edition_id: '{$options['edition_id']}',
                   rating_initial_value: '{$options['value']}',
                   rating_function_name: '{$function}', // this is function name for click
                   directory: '".$this->webroot."img'
               });";
	unset($options['edition_id']);
    $input = $this->Form->input($name, $options);
         
    $this->buffer($script);
    // $script = $this->buffer($script);
 
    // if (is_string($script)) {
      // $input .= $script;
    // }
 
    return $input;
  }

}
